"""
@File: handler.py
@Project: 约个球
@Author: zhangjian
@Time: 2022.8.27 16:33
@Description: None
"""
from flask_restful import HTTPException
from libs.error_code import APIException


def default_error_handler(ex):
    """无论什么异常  都返回APIException"""
    if isinstance(ex, APIException):
        return ex
    if isinstance(ex, HTTPException):
        code = ex.code
        message = ex.description
        status_code = 10001
        return APIException(code=code, message=message, status_code=status_code)
    return APIException()